package com.test01;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;

public class msg {
    public static void main(String[] args) {
        new Win2();
    }
}
class Win2 extends JFrame{
    JLabel name = new JLabel("姓名：");
    JLabel sex = new JLabel("性别：");
    JLabel fbr = new JLabel("爱好：");
    JLabel jig = new JLabel("籍贯：");
    JTextField name1 = new JTextField(10);
    JRadioButton sex1 = new JRadioButton("男");
    JRadioButton sex2 = new JRadioButton("女");
    JCheckBox fbr1 = new JCheckBox("体育");
    JCheckBox fbr2 = new JCheckBox("音乐");
    JCheckBox fbr3 = new JCheckBox("美术");
    JComboBox jig1 = new JComboBox();
    JButton submit = new JButton("确定");
    JTextArea context = new JTextArea(6,15);
    ButtonGroup group;
    void init(){
        setLayout(new FlowLayout());
        Box v1 = Box.createHorizontalBox();
        v1.add(name);
        v1.add(name1);
        add(v1);
        v1 = Box.createHorizontalBox();
        v1.add(sex);
        group = new ButtonGroup();
        group.add(sex1);
        group.add(sex2);
        v1.add(sex1);
        v1.add(sex2);
        add(v1);
        v1 = Box.createHorizontalBox();
        v1.add(fbr);
        v1.add(fbr1);
        v1.add(fbr2);
        v1.add(fbr3);
        add(v1);
        v1 = Box.createHorizontalBox();
        v1.add(jig);
        jig1.addItem("浙江");
        v1.add(jig1);
        add(v1);
        add(submit);
        submit.addActionListener(e->{
            StringBuilder sb = new StringBuilder();
            sb.append("姓名：").append(name1.getText()+ ' ');
            if(sex1.isSelected()) sb.append("性别：男 ");
            else sb.append("性别：女 ");
            sb.append("爱好:");
            if(fbr1.isSelected()) sb.append(" 体育 ");
            if(fbr2.isSelected()) sb.append(" 音乐 ");
            if(fbr3.isSelected()) sb.append(" 美术 ");
            sb.append("籍贯："+jig1.getSelectedItem());
            context.setText(sb.toString());
        });
        JScrollPane jsp = new JScrollPane(context);
        add(jsp);
    }
    public Win2(){
        init();
        setBounds(300,200,250,300);
        setTitle("信息录用");
        setVisible(true);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
}